% Copyright (C) 2009,2010,2011,2012  Marco Restelli
%
% This file is part of:
%   LDGH -- Local Hybridizable Discontinuous Galerkin toolkit
%
% LDGH is free software: you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% LDGH is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
% License for more details.
%
% You should have received a copy of the GNU General Public License
% along with LDGH. If not, see <http://www.gnu.org/licenses/>.
%
% author: Marco Restelli                   <marco.restelli@gmail.com>


function [t,ex,ey] = new2d_grid_singlesquare(iverts,orientation)
% This function should be only called from new2d_grid. It computes the
% two triangles used to represent a square. The input parameters are
% the vertices of the square, and a string specifying the desired
% orientation, which must be one of the following: north, south.

 ex = zeros(5,1,2); ey = ex;

 switch orientation
  case 'north'
   tt = [ 1 1;
          3 4;
          4 2 ];
  case 'south'
   tt = [ 1 2;
          3 3;
          2 4 ];
  otherwise
   error(['Wrong orientation "',orientation,'"']);
 endswitch

 t = iverts(tt);
 ex(1:2,:,1) = iverts([1,2]'); ex(5,:,1) = 2;
 ex(1:2,:,2) = iverts([3,4]'); ex(5,:,2) = 4;
 ey(1:2,:,1) = iverts([1,3]'); ey(5,:,1) = 3;
 ey(1:2,:,2) = iverts([2,4]'); ey(5,:,2) = 1;

return

